package com.jrtc.backend.controller;

import com.jrtc.base.config.dto.ResultDTO;
import com.jrtc.base.config.dto.ResultDTOBuilder;
import com.jrtc.base.entity.bo.CatchBallRecord;
import com.jrtc.base.entity.bo.PatientInvestigation;
import com.jrtc.base.entity.vo.CatchBallRecordVo;
import com.jrtc.base.entity.vo.PatientInvestigationVo;
import com.jrtc.service.CatchBallRecordService;
import com.jrtc.service.PatientInvestigationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("investigation")
public class PatientInvestigationController {
    /**
     * 服务对象
     */
    @Resource
    private PatientInvestigationService patientInvestigationService;

    /**
     * 添加患者问卷记录
     * */
    @PostMapping("/investigation")
    public ResultDTO investigation(@RequestBody PatientInvestigationVo patientInvestigationVo){
        int i;
        try {
            i = patientInvestigationService.investigation(patientInvestigationVo);
        } catch (Exception e){
            return ResultDTOBuilder.failure(e.getMessage());
        }

        if (i > 0){
            return ResultDTOBuilder.success("添加成功");
        }
        else {
            return ResultDTOBuilder.failure("添加失败");
        }
    }
}